package bsh;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import bsh.meta.FieldDescriptor;
import bsh.utils.reflection.OpenClassLoader;

/**
 * A trait is like an interface that may contain method implementations and initializer code
 * 
 * @author takeshi
 */
public interface Trait {

    /**
     * @return list of initializer code
     */
    List<BytecodeGenerator> instanceInitializers();

    /**
     * @return list of fields defined by this trait
     */
    List<FieldDescriptor> instanceFields();

    /**
     * @return list of inherited traits
     */
    List<? extends Trait> implementedTraits();

    /**
     * Loads this trait using the given classloader
     * 
     * @param loader {@link OpenClassLoader}
     * @return {@link LoadedTrait}
     */
    LoadedTrait load(OpenClassLoader loader);

    /**
     * @return a map with all types that are imported. These are inherited as well. The resulting map may contain inner classes and
     * interfaces defined on this {@link Trait}
     */
    Map<String, Class<?>> allTypeImports();

    /**
     * @return {@link Collection} with all wildcard imports
     */
    Collection<? extends String> allWildcardImports();
}
